import { goodsTabList, goodsList, goodsDetail } from './mockData'
import request from './request'

export const getGoodsTabListApi = async (params) => {
  return request({
    url: '/goods/tabList',
    method: 'GET',
    data: params
  }, goodsTabList)
}

export const getGoodsListApi = async (id, searchText) => {
  let cacheGoodsList = goodsList
  if (searchText) {
    cacheGoodsList = goodsList.filter(item => item.code.includes(searchText))
  }
  return request({
    url: `/goods/list/${id}`,
    method: 'GET'
  }, cacheGoodsList)
}

export const getGoodsDetailApi = async (id) => {
  return request({
    url: `/goods/detail/${id}`,
    method: 'GET'
  }, goodsDetail)
}
